﻿using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HelloWPF.DataBinding.DBAccess;
using HelloWPF.DataBinding.Model;
using HelloWPF.DataBinding.View;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace HelloWPF.DataBinding
{
    public class TeacherViewModel : ViewModelBase
    {
        /// <summary>
        /// 数据属性Teacher
        /// </summary>
        private Teacher _teacher;
        public Teacher Teacher
        {
            get { return _teacher; }
            set { _teacher = value; RaisePropertyChanged(); }
        }

        #region 命令属性
        public RelayCommand<object> SaveCommand { get; set; }

        public RelayCommand<object> CancelCommand { get; set; }
        #endregion

        /// <summary>
        /// 窗口传递进来
        /// </summary>
        /// <param name="teacher"></param>
        /// <param name="win"></param>
        public TeacherViewModel(Teacher teacher)
        {
            Teacher = teacher;
            SaveCommand = new RelayCommand<object>((t)=> {
                (t as Window).DialogResult = true;
            });
            CancelCommand = new RelayCommand<object>((t) => {
                (t as Window).DialogResult = false;
            });
        }
    }
}
